package com.alipay.app.groupmeal.standard.ui.c.pre;

import android.os.Build;
import android.view.Display;
import android.view.KeyEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.alipay.app.groupmeal.standard.R;
import com.alipay.app.groupmeal.standard.base.BasePresentation;
import com.alipay.app.groupmeal.standard.constant.BaseConstant;
import com.alipay.app.groupmeal.standard.constant.ConfigConstant;
import com.alipay.app.groupmeal.standard.offline.bean.FkBean;
import com.alipay.app.groupmeal.standard.ui.c.SelectPayActivity;

//BasePresentation
public class SelectPayMainPre extends BasePresentation {

    private SelectPayActivity mActivity;
    private TextView mTvCloseTime;
    private TextView mTvAmount;
    private TextView mBtnFace;
    private TextView mBtnQr;
    private TextView stateTv;
    private ImageView backImage;
    private LinearLayout paySelectLinear;


    private LinearLayout cardInfoLinear;
    private TextView cardNoTv;
    private TextView nameTv;
    private TextView btyeTv;
    private TextView kyeTv;


    @Override
    public boolean onKeyEventBack(KeyEvent event) {
        mActivity.onKeyEventBack(event);
        return super.onKeyEventBack(event);
    }

    //5074
    public SelectPayMainPre(SelectPayActivity outerContext, Display display) {
        super(outerContext, display);
        mActivity = outerContext;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
        } else {
            getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
        }

    }

    @Override
    protected int getLayoutId() {
        if (ConfigConstant.displayType == BaseConstant.DISPLAY_TYPE.T2) {
            return R.layout.activity_select_pay_ft2;
        } else {
            return R.layout.activity_select_pay;
        }
    }

    @Override
    protected void initView() {
        mTvCloseTime = findViewById(R.id.tv_close_time);
        mTvAmount = findViewById(R.id.tv_amount);
        mBtnFace = findViewById(R.id.btn_face);
        mBtnQr = findViewById(R.id.btn_Qr);
        stateTv = findViewById(R.id.stateTv);
        paySelectLinear = findViewById(R.id.paySelectLinear);
        backImage = findViewById(R.id.backImage);
        cardInfoLinear = findViewById(R.id.cardInfoLinear);
        cardNoTv = findViewById(R.id.cardNoTv);
        nameTv = findViewById(R.id.nameTv);
        btyeTv = findViewById(R.id.btyeTv);
        kyeTv = findViewById(R.id.kyeTv);
    }

    @Override
    protected void initData() {

    }

    public TextView getmTvCloseTime() {
        return mTvCloseTime;
    }

    public void setmTvCloseTime(TextView mTvCloseTime) {
        this.mTvCloseTime = mTvCloseTime;
    }

    public TextView getmTvAmount() {
        return mTvAmount;
    }

    public void setmTvAmount(TextView mTvAmount) {
        this.mTvAmount = mTvAmount;
    }

    public TextView getmBtnFace() {
        return mBtnFace;
    }

    public void setmBtnFace(TextView mBtnFace) {
        this.mBtnFace = mBtnFace;
    }

    public TextView getmBtnQr() {
        return mBtnQr;
    }

    public void setmBtnQr(TextView mBtnQr) {
        this.mBtnQr = mBtnQr;
    }

    public TextView getStateTv() {
        return stateTv;
    }

    public void setStateTv(TextView stateTv) {
        this.stateTv = stateTv;
    }

    public LinearLayout getPaySelectLinear() {
        return paySelectLinear;
    }

    public void setPaySelectLinear(LinearLayout paySelectLinear) {
        this.paySelectLinear = paySelectLinear;
    }

    public ImageView getBackImage() {
        return backImage;
    }

    public void setBackImage(ImageView backImage) {
        this.backImage = backImage;
    }

    public void showError(String error, FkBean fkBean) {
        stateTv.setText(error);
        paySelectLinear.setVisibility(View.GONE);
        backImage.setImageResource(R.mipmap.ic_err_bg);
        if (fkBean != null) {
//            cardInfoLinear.setVisibility(View.VISIBLE);
            cardNoTv.setText("卡号：" + fkBean.getCardno());
            nameTv.setText("姓名：" + fkBean.getName());
            btyeTv.setText("补贴余额：" + fkBean.getBtye());
            kyeTv.setText("卡余额：" + fkBean.getKye());
        }
    }

    public void showSuccess(FkBean fkBean) {
        paySelectLinear.setVisibility(View.GONE);
//        cardInfoLinear.setVisibility(View.VISIBLE);
        cardNoTv.setText("卡号：" + fkBean.getCardno());
        nameTv.setText("姓名：" + fkBean.getName());
        btyeTv.setText("补贴余额：" + fkBean.getBtye());
        kyeTv.setText("卡余额：" + fkBean.getKye());
    }
}